package com.poisonh.unifiedauth.dialog;

import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;

import com.poisonh.unifiedauth.R;

/**
 * 软件更新对话框
 * Created by PoisonH on 2016/9/1.
 */
public class UpdateDialogFragment extends DialogFragment implements View.OnClickListener
{
    private Button mBtnCancel;
    private Button mBtnUpdateApp;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        //去掉标题栏
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        return inflater.inflate(R.layout.layout_dialog_updateapp, null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState)
    {
        super.onViewCreated(view, savedInstanceState);
        mBtnCancel = (Button) view.findViewById(R.id.btn_cancel);
        mBtnUpdateApp = (Button) view.findViewById(R.id.btn_updateapp);
        mBtnUpdateApp.setOnClickListener(this);
        mBtnCancel.setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
        switch (v.getId())
        {
            case R.id.btn_cancel:
                dismiss();
                break;
            case R.id.btn_updateapp:
                UpdateAppListener listener = (UpdateAppListener) getActivity();
                listener.onUpdateAppListener(true);
                dismiss();
                break;
        }
    }

    public interface UpdateAppListener
    {
        void onUpdateAppListener(boolean update);
    }
}
